package com.sdehl.kafkatransfer.constant.enums;

import lombok.Getter;

import java.util.Objects;

/**
 * @author Jiax
 * @version 1.0.0
 * @description: DriveDirectionEnum
 * @date 2023-10-13 14:52
 */
@Getter
public enum DriveDirectionEnum {

    E_TO_W("01","由东向西"),
    W_TO_E("02","由西向东"),
    S_TO_N("03","由南向北"),
    N_TO_S("04","由北向南"),
    E_TO_S("05","由东向南"),
    W_TO_S("06","由西向南"),
    E_TO_N("07","由东向北"),
    W_TO_N("08","由西向北"),
    S_TO_E("09","由南向东"),
    S_TO_W("10","由南向西"),
    N_TO_E("11","由北向东"),
    N_TO_W("12","由北向西"),
    OTHER("99","其他"),
    ;
    /**
     * 编码
     */
    private String code;
    /**
     * 中文名称
     */
    private String name;

    DriveDirectionEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据code查询行驶方向枚举
     * @param code
     * @return
     */
    public static DriveDirectionEnum getByCode(String code) {
        for (DriveDirectionEnum directionEnum : values()) {
            if (Objects.equals(directionEnum.getCode(), code)) {
                return directionEnum;
            }
        }
        return null;
    }

    /**
     * 根据code查询行驶方向枚举
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        for (DriveDirectionEnum directionEnum : values()) {
            if (Objects.equals(directionEnum.getCode(), code)) {
                return directionEnum.getName();
            }
        }
        return null;
    }

}
